package Demo1;

import java.util.LinkedList;
import java.util.Queue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-07-18
 * Time: 12:20
 */
public class Test {
    public boolean isTree(TreeNode root){
        if(root == null){
            return true;
        }
        Queue<TreeNode> queue = new LinkedList<>();
        queue.offer(root);

        TreeNode cur = root;
        while(cur != null){
            cur = queue.poll();
            queue.offer(cur.left);
            queue.offer(cur.right);
        }
        int size = queue.size();
        while(size != 0){
            TreeNode ret = queue.poll();
            if(ret != null){
                return false;
            }
            size--;
        }
        return true;
    }
    public static void main(String[] args) {

    }
}
